package com.atguigu.acyjl;

import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {

    List<String> allExplanations = new ArrayList<>();

    public void setAllExplanations(List<String> allExplanations) {
        this.allExplanations = allExplanations;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
        View itemView = layoutInflater.inflate(R.layout.cell_normal,parent,false);
        return new MyViewHolder(itemView);
//        return null;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        String str = allExplanations.get(position);
        holder.cellText.setText(str);


    }

    @Override
    public int getItemCount() {
        return allExplanations.size();
    }

    static class MyViewHolder extends RecyclerView.ViewHolder {
        TextView cellText;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            cellText = itemView.findViewById(R.id.cellText);
        }
    }
}
